a{{extend '../_layouts/home.html'}}

{{block 'title'}}{{'多人博客 - 首页'}}{{/block}}
{{block 'head'}}
<style>
.breadcrumb a.active{
    color:black
}
</style>
{{/block}}
{{block 'body'}}

<section class="container">
    <ol class="breadcrumb">
        <li><a class="{{cshare}}" href="myshare">分享</a></li>
        <li><a class="{{cquestion}}" href="myquestion">问答</a></li>
        <li><a class="{{crecruitment}}" href="myrecruitment">招聘</a></li>
      </ol>
    <ul class="media-list">
    {{each mydata}}
    <li class="media">
        <div class="media-left">
          <a href="#">
              <img width="40" height="40" class="media-object" src="{{$value.avatar}}" alt="...">
            </a>
        </div>
        <div class="media-body">
          <h4 class="media-heading"><a href="{{$value.type}}?id={{$value._id}}">{{$value.title}}</a></h4>
          <p>  {{$value.comments.length}} 个回复 • {{$value.browse}} 次浏览 • {{$value.time}}</p>
        </div>
        <a href="/edit/{{$value.type}}?id={{$value._id}}" class="btn btn-primary">编辑</a>
        <input data-id="{{$value._id}}" data-type="{{$value.type}}" type="button" class="btn btn-danger delBtn" value="删除">
       
      </li>
  {{/each}}
  </ul>
</section>
{{/block}}
{{block "script"}}
    <script>
        $(".delBtn").click(function (){
            $.ajax({
                type:"get",
                url:"/delete?id="+$(this).attr("data-id")+"&type="+$(this).attr("data-type"),
                success:()=>{
                    alert("删除成功");
                    window.location.reload();
                },
                error:()=>{
                    alert("删除失败")
                }
            })
        })
    </script>
{{/block}}